package zju.cst.seckill;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.tomcat.util.digester.Digester;

/**
 * @className: MD5Util
 * @description:
 * @author: wbr
 * @date: 2019-07-29 00:58
 */
public class MD5Util {
    /**
     * 用户输的密码，做个md5，
     * 存储到数据库的时候，拿md5过之后的md5再一次随机md5
     */
    private static final String salt = "1asecu";
    public static String md5(String src){
        return DigestUtils.md2Hex(src);
    }
    //用户输入的密码转换成
    public static String inputPassFromPass(String inputPass){
        String s = salt.charAt(0)+salt.charAt(2)+inputPass+salt.charAt(5)+salt.charAt(4);
        return DigestUtils.md2Hex(s);
    }
    public static String fromPassToDB(String fromPass,String salt){
        String s = salt.charAt(0)+salt.charAt(2)+fromPass+salt.charAt(5)+salt.charAt(4);
        return DigestUtils.md2Hex(s);
    }
}
